<template>
  <el-menu :default-active="activeIndex" class="el-menu-vertical-demo" @select="handleSelect">
    <el-sub-menu index="1">
      <template #title>
        <el-icon><House /></el-icon>
        <span>工作台</span>
      </template>
      <el-menu-item index="/xwbl">询(讯)问笔录</el-menu-item>
    </el-sub-menu>
    <el-sub-menu index="2" >
      <template #title>
        <el-icon><Setting /></el-icon>
        <span>系统管理</span>
      </template>
      <el-menu-item index="/user" v-if="username=='admin'">用户管理</el-menu-item>
      <el-menu-item index="/system">系统属性</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script lang="ts" setup>
import { ref, reactive ,onMounted} from 'vue'
import { useRouter } from 'vue-router';
const router = useRouter();
const username = ref('')

const activeIndex = ref(router.currentRoute.value.path)

onMounted(() => {
  username.value = sessionStorage.getItem('username')
})
const handleSelect = (key, keyPath) => {
  router.push({ path: key })
}
</script>

<style lang="scss" scoped></style>
